package demo;

import com.alibaba.excel.EasyExcel;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class Demo02 {
    public static void main(String[] args) {
        /*
         * 写一个Excel文件
         */
        String file = "excel/poster.xlsx";
        //准备写出的数据
        List<Post> posts = new ArrayList<>();
        posts.add(new Post(1, "Tom",
                LocalDateTime.now(), "Hello World"));
        posts.add(new Post(2, "Jerry",
                LocalDateTime.now(), "昨天下雪了"));
        posts.add(new Post(3, "老王",
                LocalDateTime.now(), "今天天气不错"));
        posts.add(new Post(4, "熊大",
                LocalDateTime.now(), "光头强在哪里？"));
        //写到Excel文件中
        EasyExcel.write(file, Post.class).sheet("发帖列表").doWrite(posts);

    }
}
